<template>
	<view>
		<view class="cu-bar bg-white">
			<view class="action border-title">
				<text class="cuIcon-titles text-green"></text>
				<text class="text-xl text-bold">{{title}}</text>
			</view>
		</view>
		<form v-for="(item, index) in purchaseMoneyInfo" :key="index">
			<view class="cu-form-group margin-top">
				<view class="title">物品名称</view>
				<view>
					<text class="label">
						{{ item.itemName }}
					</text>
					<button class='cu-btn bg-green shadow' @click="openSearchOther(item)">其他</button>
				</view>
			</view>
			<view class="cu-form-group">
				<view class="title">物品代码</view>
				<view>
					<text class="label">
						{{ item.itemCode }}
					</text>
					<button class='cu-btn bg-green shadow' @click="openSearchPrice(item)">其他</button>
				</view>
			</view>
			<view class="cu-form-group">
				<view class="title">供应商</view>
				<view> {{ item.supplierName }} </view>
			</view>
			<view class="cu-form-group">
				<view class="title">规格</view>
				<view> {{ item.specification }} </view>
			</view>
			<view class="cu-form-group">
				<view class="title">原价</view>
				<view> {{ item.oldPrice }}元</view>
			</view>
			<view class="cu-form-group">
				<view class="title">现价</view>
				<view style="color: red"> {{ item.newPrice }}元 </view>
			</view>
			<view class="cu-form-group">
				<view class="title">情况说明</view>
				<view> {{ item.remark || '' }} </view>
			</view>
			<view class="cu-list menu sm-border card-menu" v-for="(item, index) in purchasemoneyList[index]"
				:key="index">
				<!-- 多行Item -->
				<view class="cu-item">
					<view class="content padding-tb-sm">
						<view>
							<text class="cuIcon-deliver_fill margin-right-xs"></text> {{item.name}}
						</view>
						<view class="text-black text-xl">
							<text class="cuIcon-rechargefill margin-right-xs"></text> {{item.price}}元
						</view>
					</view>
					<view class="action">
						<view class='cu-tag radius bg-red' v-if="item.status == 1">圆角</view>
						<view class="" v-else> </view>
					</view>
				</view>
			</view>
		</form>
	</view>
</template>

<script>
	import {
		getPurchasemoney,
		getItemSupplier,
		getOtherPrice,
		getSuppliersList
	} from '@/api/approve'
	export default {
		name: "PurchaseMoney",
		data() {
			return {
				purchaseMoneyInfo: {},
				title: "采购金额修改审批详情",
				item: {},
				purchasemoneyList: []
			};
		},
		props: {
			forms: {
				type: Object,
				default: () => {
					return {}
				}
			},
			value: {
				type: Object,
				default: () => {
					return {}
				}
			},
		},
		mounted() {
			uni.setNavigationBarTitle({
				title: '采购金额修改审批详情'
			});
			this.purchaseMoneyInfo = JSON.parse(this.forms.list)
			this.getPurchase()
		},
		methods: {
			// 其他供应商价格
			getPurchase() {
				this.purchasemoneyList = []
				this.purchaseMoneyInfo.forEach(item => {
					getPurchasemoney({
						itemCode: item.itemId
					}).then((res) => {
						this.purchasemoneyList.push(res.item)
					});
				})
			},
		
			openSearchOther(item) {
				this.$mRouter.push({
					route: `/pages/works/detail/otherSupplier/otherSupplier?itemName=${item.itemName}`
				})
			},
			
			openSearchPrice(item) {
				this.$mRouter.push({
					route: `/pages/works/detail/otherPrice/otherPrice?itemCode=${item.itemCode}&newPrice=${item.newPrice}`
				})
			},
		}
	}
</script>

<style scoped>
	.cu-form-group .title {
		min-width: calc(4em + 15px);
	}
</style>